package com.fimuz.mqmeet.api.roombook.control;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.fimuz.mqmeet.api.roombook.service.RoombookService;
import com.fimuz.mqmeet.api.roombook.service.model.CreateSpModel;
import com.fimuz.mqmeet.api.roombook.service.model.CreateSrModel;
import com.fimuz.mqmeet.api.roombook.service.model.DeleteSpModel;
import com.fimuz.mqmeet.api.roombook.service.model.DeleteSrModel;
import com.fimuz.mqmeet.api.roombook.service.model.GetBoardRoomSpModel;
import com.fimuz.mqmeet.api.roombook.service.model.GetBoardRoomSrModel;
import com.fimuz.mqmeet.api.roombook.service.model.GetSpModel;
import com.fimuz.mqmeet.api.roombook.service.model.GetSrModel;
import com.fimuz.mqmeet.api.roombook.service.model.ListBoardRoomSpModel;
import com.fimuz.mqmeet.api.roombook.service.model.ListBoardRoomSrModel;
import com.fimuz.mqmeet.api.roombook.service.model.UpdateSpModel;
import com.fimuz.mqmeet.api.roombook.service.model.UpdateSrModel;
import com.fosun.spr.core.base.CoBaseControl;
import com.fosun.spr.core.utils.SessionUtils;

@Controller
public class RoombookControl extends CoBaseControl {
	//@Autowired
	@Resource
	private RoombookService roombookService;

	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/roombook/listBoardRoom
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/roombook/listBoardRoom",method = RequestMethod.GET)
	public ListBoardRoomSrModel listBoardRoom(HttpServletRequest request, ListBoardRoomSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		ListBoardRoomSrModel srModel = roombookService.listBoardRoom(spModel);
		return srModel;
	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/roombook/getBoardRoom
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/roombook/getBoardRoom",method = RequestMethod.GET)
	public GetBoardRoomSrModel getBoardRoom(HttpServletRequest request, GetBoardRoomSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		GetBoardRoomSrModel srModel = roombookService.getBoardRoom(spModel);
		return srModel;
	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/roombook/update
{
	"id":"",
	"durationMins":0,
	"meetTilte":"",
	"meetTime":"",
	"memo":"",
	"roomId":""
}
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/roombook/update",method = RequestMethod.POST)
	public UpdateSrModel update(HttpServletRequest request,@RequestBody UpdateSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		UpdateSrModel srModel = roombookService.update(spModel);
		return srModel;
	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/roombook/create
{
	"durationMins":0,
	"meetTilte":"",
	"meetTime":"",
	"memo":"",
	"roomId":""
}


	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/roombook/create",method = RequestMethod.POST)
	public CreateSrModel create(HttpServletRequest request,@RequestBody CreateSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		CreateSrModel srModel = roombookService.create(spModel);
		return srModel;
	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/roombook/get
	 * 
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/roombook/get",method = RequestMethod.GET)
	public GetSrModel get(HttpServletRequest request, GetSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		GetSrModel srModel = roombookService.get(spModel);
		return srModel;
	}
	/**
	 * http://127.0.0.1:8080/mq_meet_server/api/roombook/delete
{
	"id":"1498837070711-28afcca9-d064-4bc1-93b3-03a23aadc05a"
}
	 * @param request
	 * @param spModel
	 * @return
	 */	
	@RequestMapping(value = "/api/roombook/delete",method = RequestMethod.POST)
	public DeleteSrModel delete(HttpServletRequest request,@RequestBody DeleteSpModel spModel) {
		SessionUtils.fillSpModel(request, spModel);
		DeleteSrModel srModel = roombookService.delete(spModel);
		return srModel;
	}
	
	//生成成json的代码
	public static void main(String[] args) throws Exception{
		debugPrintJsonSpModel(new UpdateSpModel());
		debugPrintJsonSpModel(new CreateSpModel());
	}	
}
